#include <iostream>
#include <string.h>
using namespace std;
class Phone{
public:
    Phone(string pName){
        m_PName = pName;
        cout << "1" << endl;
    }
    ~Phone(){
       
        cout << "4" << endl;
    }
    //手机品牌名称
    string m_PName;
};
class Person{
public:
// Phone m_Phone = pName  隐式转换法
    Person(string name,string pName):m_Name(name),m_Phone(pName){
        cout << "2" << endl;
    }
    ~Person(){
        cout << "3" << endl;
    }
    Phone m_Phone;
    string m_Name;
};

void test01(){
    Person p("张三","苹果MAX");
    cout << p.m_Name << "拿着" << p.m_Phone.m_PName << endl;
}

//B类中有对象A作为成员，A为对象成员
//那么当创建B对象时，A与B的构造和析构的顺序是谁先谁后？
// 当其他类对象作为本类的成员，构造时候县构造类对象，再构造自身
// 析构的顺序与构造相反
int main(){
    test01();
	system("pause");
	return 0;
}

